<?
include_once 'include/include.php';
c_create::createClass('setPage');
$page = new setPage();
c_create::createClass('news');
$news = new news();
$outvar[headline] = '新闻管理列表';
if ($_GET[did]){
	if ($news->deleteRecord($_GET[did])){
		$_SESSION[showtips]	 = '删除成功！';
	}else {
		$_SESSION[showtips]	 = '删除失败！';
	}
}
if ($_GET[Cid]){
	$where = ' and a.Cid='.$_GET[Cid];
	$outvar[Cid] = $_GET[Cid];
}
if ($_GET[search]){
	$search = $_GET[search];
	$where .= " and binary ucase(a.Atitle) like concat('%',ucase('$search'),'%')";
	$outvar[search_word] = $search;
}

$where = " where a.Adeleted='n' $where order by a.Articleid desc";
$query = "select count(*) from ".$dbtable->news.' a'.$where;
$page->setPagePHP(20,10,$dbconn->Getonefield($query));
$query = "select a.*,b.Ccataname from ".$dbtable->news.' a left join '.$dbtable->newscata.' b on(a.Cid=b.Cid)'.$where.$page->limit;
$nowQueryid = $dbconn->Query($query);
$i = 0;
while (($row = $dbconn->next_record($nowQueryid))){
	$row[num] = $i+1;
	$row[Atitle_sub] = cut_str($row[Atitle],30);
	$row[Atitle_sub] = str_replace($_GET[search],'<b class="red">'.$_GET[search].'</b>',$row[Atitle_sub]);
	$row[Ccataname] = $row[Ccataname]?$row[Ccataname]:'无类';
	$array[] = $row;
	$i++;
}
$outvar[page] = $page->menuAll;
$outvar[record] = $array;
$outvar[fileurl_1] = getFileWithVar('',array('id','did'));
$outvar[fileurl_2] = getFileWithVar('',array('id','did','Cid'));
$outvar[typelist] = $news->getTypeList();
outFile("news_manage");
?>